package desktop.core.bar;

import desktop.core.square.Square;
import desktop.core.square.SquareFactory;

public class BarBuilder {

	private static BarBuilder builder = new BarBuilder();

	private BarBuilder() {
	}

	public static BarBuilder getBuilder() {
		return BarBuilder.builder;
	}

	public Bar produceBar(double x, double y, double widthUnit,
			double heightUnit, double gravitySpeed, int column, int row) {
		Square[][] squares = new Square[column][row];
		for (int i = 0; i < column; i++) {
			for (int j = 0; j < row; j++) {
				squares[i][j] = SquareFactory.getFactory().createSquare(
						widthUnit * i, heightUnit * j, widthUnit, heightUnit);
			}
		}
		return new Bar(x, y, widthUnit * column, heightUnit * row, column, row,
				squares, gravitySpeed);
	}
}